package com.bailian.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.bailian.system.domain.vo.BlAppointmentVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bailian.common.annotation.Log;
import com.bailian.common.core.controller.BaseController;
import com.bailian.common.core.domain.AjaxResult;
import com.bailian.common.enums.BusinessType;
import com.bailian.system.domain.BlAppointment;
import com.bailian.system.service.IBlAppointmentService;
import com.bailian.common.utils.poi.ExcelUtil;
import com.bailian.common.core.page.TableDataInfo;

/**
 * 仓库预约列表Controller
 * 
 * @author bailian
 * @date 2025-08-04
 */
@RestController
@RequestMapping("/system/appointment")
public class BlAppointmentController extends BaseController
{
    @Autowired
    private IBlAppointmentService blAppointmentService;

    /**
     * 查询仓库预约列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:appointment:list')")
    @GetMapping("/list")
    public TableDataInfo list(BlAppointment blAppointment)
    {
        startPage();
        List<BlAppointmentVo> list = blAppointmentService.selectBlAppointmentVoList(blAppointment);
        return getDataTable(list);
    }

    /**
     * 导出仓库预约列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:appointment:export')")
    @Log(title = "仓库预约列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlAppointment blAppointment)
    {
        List<BlAppointment> list = blAppointmentService.selectBlAppointmentList(blAppointment);
        ExcelUtil<BlAppointment> util = new ExcelUtil<BlAppointment>(BlAppointment.class);
        util.exportExcel(response, list, "仓库预约列表数据");
    }

    /**
     * 获取仓库预约列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:appointment:query')")
    @GetMapping(value = "/{appointmentId}")
    public AjaxResult getInfo(@PathVariable("appointmentId") Long appointmentId)
    {
        return success(blAppointmentService.selectBlAppointmentVoByAppointmentId(appointmentId));
    }

    /**
     * 新增仓库预约列表
     */
    @PreAuthorize("@ss.hasPermi('system:appointment:add')")
    @Log(title = "仓库预约列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BlAppointment blAppointment)
    {
        return toAjax(blAppointmentService.insertBlAppointment(blAppointment));
    }

    /**
     * 修改仓库预约列表
     */
    @PreAuthorize("@ss.hasPermi('system:appointment:edit')")
    @Log(title = "仓库预约列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BlAppointment blAppointment)
    {
        return toAjax(blAppointmentService.updateBlAppointment(blAppointment));
    }

    /**
     * 删除仓库预约列表
     */
    @PreAuthorize("@ss.hasPermi('system:appointment:remove')")
    @Log(title = "仓库预约列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{appointmentIds}")
    public AjaxResult remove(@PathVariable Long[] appointmentIds)
    {
        return toAjax(blAppointmentService.deleteBlAppointmentByAppointmentIds(appointmentIds));
    }
}
